-
Notifications
You must be signed in to change notification settings - Fork 369
Update babylon-support branch to use es6 imports, module-level GTLF loader function, auto-detect plugin extension, and add/remove observables #1397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: babylon-support
Are you sure you want to change the base?
Conversation
georginahalpern
commented
Dec 11, 2025
- Update dependency to es6 and more recent babylon version
- Update imports to avoid import * from BABYLON
- Update gltfLoader to use module-level gltfloader ImportFileAsync (to enable treeshaking)
- Update gltfLoader to detect plugin extension vs hardcode glb
- Integrate babylon observables into add/remove event listeners
gkjohnson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thanks! Just a few small changes and questions. I'll fix some of the lint errors in the other branch - looks like the CI only runs on PR into master.
| @@ -1,4 +1,4 @@ | |||
| import * as BABYLON from 'babylonjs'; | |||
| import { Scene, Engine, Vector3, ArcRotateCamera } from '@babylonjs'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to import from @babylonjs/core?
| /** | ||
| * Detect if buffer contains GLB binary data by checking magic bytes | ||
| * @param {ArrayBuffer|Uint8Array} buffer - The file buffer | ||
| * @returns {boolean} True if GLB format | ||
| */ | ||
| isGLB( buffer ) { | ||
|
|
||
| // Handle both ArrayBuffer and typed arrays (e.g., Uint8Array) | ||
| const arrayBuffer = buffer instanceof ArrayBuffer ? buffer : buffer.buffer; | ||
| const byteOffset = buffer instanceof ArrayBuffer ? 0 : buffer.byteOffset; | ||
| const byteLength = buffer.byteLength; | ||
|
|
||
| if ( byteLength < 4 ) { | ||
|
|
||
| return false; | ||
|
|
||
| } | ||
|
|
||
| const view = new DataView( arrayBuffer, byteOffset, byteLength ); | ||
| const magic = view.getUint32( 0, true ); // little-endian | ||
| return magic === GLB_MAGIC; | ||
|
|
||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be sure: there's no way for Babylon to determine whether a file is a binary or ascii glTF automatically?
| "babylonjs": "^7.0.0", | ||
| "babylonjs-loaders": "^7.0.0", | ||
| "@babylonjs/core": "^8.39.3", | ||
| "@babylonjs/loaders": "^8.39.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's update the "peerDependencies" section, too. I'll let you decide which versions are needed for the current babylon support but >=8.0.0 seem reasonable to me.